package com.beiding.fastmock.utils;

import com.alibaba.fastjson.JSON;
import com.beiding.dbrequest.common.Common;
import com.beiding.fastmock.fram.call.Data;

import java.util.HashMap;
import java.util.Map;

/**
 * @author 丁常磊
 * @date 2021/7/17 11:25
 */

public class PluginUtils {
    public static Map<String, Object> createResult(int status, byte[] body) {
        Map<String, Object> obj = new HashMap<>();
        obj.put("status", status);
        if (body != null) {
            obj.put("body", JSON.parse(new String(body, Common.CHARSET)));
        }
        return obj;
    }

    public static byte[] toByteArray(Data data) {
        return data.toJSONString().getBytes(Common.CHARSET);
    }

}
